import { PreloadingStrategy, Route } from '@angular/router';
import { Observable } from 'rxjs';

/**
 * 预加载策略:
 * 读取route.data.preload的值, 若为true 预加载该模块
 */
export class LoadMarkedPreloadStrategy implements PreloadingStrategy {

    preload(route: Route, fn: () => Observable<any>): Observable<any> {
        return route.data.preload ? fn() : Observable.of(null);
    }
}
